// pages/explore/explore.js
Page({

  /**
   * Page initial data
   */
  data: {
    beacons: []
  },

  /**
   * Lifecycle function--Called when page load
   */
  onLoad: function(options) {
    var self = this
    wx.startBeaconDiscovery({
      uuids: ['FDA50693-A4E2-4FB1-AFCF-C6EB07647825'],
      // uuids: ['FDA50693-A4E2-4FB1-AFCFC6-EB07647825'],
      success(res) {
        // wx.showModal({
        //   title: 'ss',
        //   content: 'ss',
        // })

        wx.onBeaconUpdate(function(res) {
          // console.log(res.beacons)
          wx.getBeacons({
            success(res) {
              self.setData({
                beacons: res.beacons
              })
              console.log(res)
            }
          })
        });
      },
      fail(res) {
        // console.log(res)
        // wx.showModal({
        //   title: res.errMsg,
        //   content: '',
        // })
      }
    })
  },

  /**
   * Lifecycle function--Called when page is initially rendered
   */
  onReady: function() {

  },

  /**
   * Lifecycle function--Called when page show
   */
  onShow: function() {

  },

  /**
   * Lifecycle function--Called when page hide
   */
  onHide: function() {

  },

  /**
   * Lifecycle function--Called when page unload
   */
  onUnload: function() {

  },

  /**
   * Page event handler function--Called when user drop down
   */
  onPullDownRefresh: function() {

  },

  /**
   * Called when page reach bottom
   */
  onReachBottom: function() {

  },

  /**
   * Called when user click on the top right corner to share
   */
  onShareAppMessage: function() {

  }
})